package com.echat.messagesender.sender.model;

import com.echat.messagesender.sender.exception.EchatSmsException;
import lombok.Builder;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Id;
import java.time.LocalDateTime;


/**
 * Created by chenmohan on 2018/09/06
 *
 * @description 短信模板类
 */
@Data
@Builder
public class SmsTemplate {

    @Id
    private Long id;

    private Long userId;

    private String name;

    private String content;

    @Column(name = "create_datetime")
    private LocalDateTime createTime;

    @Column(name = "modify_datetime")
    private LocalDateTime modifyTime;

    public void check() {
        if (userId == null) {
            throw new EchatSmsException("userId不能为空");
        }
        if (content == null) {
            throw new EchatSmsException("content不能为空");
        }
    }

}
